package com.yjhb.android.sbz.fragment;

import android.view.View;

import com.yjhb.android.sbz.adapter.ViolationPublicityAdapter;
import com.yjhb.android.sbz.entity.Violation;
import com.yjhb.android.sbz.manager.ResManager;
import com.yjhb.android.sbz.mvp.violation.ViolationPublicityPresenter;
import com.yjhb.android.sbz.mvp.violation.ViolationPublicityView;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2021/1/11 10:26
 */
public class ViolationPublicityFragment extends BaseListFragment<ViolationPublicityPresenter, ViolationPublicityAdapter, Violation> implements ViolationPublicityView {
    private final String TAG = "ViolationPublicityFragment";

    @Override
    protected ViolationPublicityAdapter getAdapter() {
        return new ViolationPublicityAdapter(getContext());
    }

    @Override
    protected CharSequence getTips() {
        return "";
    }

    @Override
    protected void initUI() {
        super.initUI();
        content_layout.setPadding(0, ResManager.dp() * 15, 0, 0);
    }

    @Override
    protected void onLoadData(int size, int current) {
        presenter.getViolateInfo(size, current);
    }

    @Override
    protected ViolationPublicityPresenter initPresenter() {
        return new ViolationPublicityPresenter(this);
    }

    @Override
    public void onItemClick(int index, Object o) {

    }

    @Override
    public void onViewClick(View view, String msg, int index, Object o) {

    }

    @Override
    public void onData(List<Violation> violations, boolean isRefresh) {
        loadingDialog.cancel();
        smartRefreshLayout.finishRefresh();
        smartRefreshLayout.finishLoadmore();
        if (isRefresh) {
            dataSet.clear();
        }
        dataSet.addAll(violations);
        adapter.notifyDataSetChanged();
    }
}
